<template>
    <div>
        <div v-if="$store.state.winWidth > 768" class="header ">
            <div class="header_con">
                <div class="logo" @click="goPage('/index')">
                    <img :src="options.second_logo" alt="">
                </div>
                <div class="menu">
                    <a @click.prevent="goPage('/index')" :href="getHref({path:'/index'})">
                        <span>首页</span>
                        <!-- <span v-if="active=='index'" class="line"></span> -->
                    </a>
                    <div @click="gother('zp')">
                        <span>招聘职位</span>
                        <!-- <span v-if="active=='zp'" class="line"></span> -->
                    </div>
                    <div @click="gother('at')">
                        <span>{{title}}</span>
                        <!-- <span v-if="active=='at'" class="line"></span> -->
                    </div>
                </div>
            </div>

        </div>
        <div v-if="$store.state.winWidth <= 768 && path=='/jobIndex'" class="mobheader">
            <div class="title"
                :style="{ backgroundColor: $store.state.winScroll > 100 || show ? '#EDEDED' : '', color: $store.state.winScroll > 100 || show ? '#000' : '#fff' }">
                <img v-if="!show" @click="show = true" class="close" src="@/assets/img/open.png" alt="">
                <img v-else class="close" @click="show = false" src="@/assets/img/close.png" alt="">
                <img @click="goPage('/index')" src="@/assets/img/logo3.png" alt="">
            </div>
            <div v-if="show" class="showMenu">
                <img  class="close" @click="show = false" src="@/assets/img/close.png" alt="">
                <div class="name">
                    <span>富贵泉</span>
                </div>
                <div class="menu2">
                    <div @click="goPage('/index')">
                        <span>首页</span>
                        <i  class="el-icon-arrow-right"/>
                    </div>
                    <div @click="gother('zp')">
                        <span>招聘职位</span>
                        <i  class="el-icon-arrow-right"/>
                    </div>
                    <div @click="gother('at')">
                        <span>{{title}}</span>
                        <i  class="el-icon-arrow-right"/>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: {
title:{
    type:String,
    default:'在富贵泉'
}
    },
    data() {
        return {
            active: '',
            show:false
        }
    },
    computed: {
        options() {
            return this.$store.state.dataInfo
        },
        path(){
            console.log(this.$route);
            
            return this.$route.path
        },
        pathName(){
            return this.$route.meta.title
        }

    },
    mounted() {
        window.addEventListener('scroll', this.handleScroll)
    },
    beforeDestroy() {
        window.removeEventListener('scroll', this.handleScroll)
    },
    methods: {
        getHref(route) {
            const resolved = this.$router.resolve(route);
            return resolved.href;
        },
        handleScroll() {
            this.scrollPosition = window.scrollY
        },
        gother(d) {
            this.show = false
            if (this.$route.path != '/jobIndex') {
                this.$router.push('/jobIndex')
                setTimeout(() => {
                    this.active = d
                    this.$emit('getther', d)
                }, 50)
                return
            }
            this.active = d
            this.$emit('getther', d)
           
        },
        goPage(url) {
            if (url) {
                this.$router.push(url)
            }

        },
    }
}
</script>

<style lang="scss" scoped>
.header {
    width: 100%;
    height: 72px;
    padding: 0px 250px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background-color: #fff;

    .header_con {
        display: flex;
        align-items: center;
        justify-content: center;

        .logo {
            cursor: pointer;
            width: 169px;
            height: 50px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;

            img {
                width: 100%;
                height: 100%;
            }
        }
    }
}

.menu {
    display: flex;
    align-items: center;
    margin-left: 200px;
    // font-weight: bold;
    color: #B00D16;
    height: 72px;
    font-size: 18px;

    >div,a {
        height: 100%;
        display: flex;
        align-items: center;
        position: relative;
        margin: 0 25px;
        cursor: pointer;
        text-decoration: none;
        color: #B00D16;
        .line {
            position: absolute;
            bottom: 0;
            height: 3px;
            border-radius: 5px;
            background-color: #B00D16;
            width: 100%;
            left: 0;

        }
    }
}
.mobheader {
    position: fixed;
    z-index: 99;
    width: 100%;
top: 0;
    background-color: #fff;
}

.title {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 249px;
    z-index: 99;
    width: 100%;

    i {
        position: absolute;
        right: 165px;
        font-size: 80px;
    }

    .close {
        width: 82px;
        height: 75px;
        position: absolute;
        right: 165px;
    }

    img {
        width: 196px;
        height: 196px;
    }
}
.showMenu{
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    padding: 240px 80px 0;
    backdrop-filter: blur(59px);
    background-color: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid transparent;
    .close {
        width: 82px;
        height: 75px;
        position: absolute;
        right: 165px;
        top: 120px;
    }
    .name{
        font-weight: bold;
        font-size: 120px;
    }
    .menu2{
        margin-top: 120px;
        >div{
            padding:  100px 0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
    }
}
</style>